<template>
  <radio-group @change="radioChange">
    <view class="radio-list" v-for="item in props.list" :key="item.type">
      <img src="https://img.qumoyugo.com/webimgbg/pets-icon-alipay-ar.png" class="img">
      <view>支付宝</view>
      <view @click="changeCurrent(item)" style="flex:1">{{item.name}}{{hideString(item.account)}}</view>
      <view>
        <radio :value="item.type" :checked="item.id === currentCheck.id" color="#E02020" style="transform:scale(0.8)" />
      </view>
    </view>
  </radio-group>
</template>

<script setup>
import { ref } from 'vue'
const current = ref({})
const props = defineProps({
  list: {
    type: Object,
    default: () => {
      return []
    }
  },
  currentCheck: {
    type: Object,
    default: () => {
      return {}
    }
  }
})

const emit = defineEmits(['change'])
const radioChange = (e) => {
  emit('change', e.detail.type)
}
const changeCurrent = (item) => {
  current.value = item.type
  emit('change', item.type)
}
const hideString = (str) => {
  if (!str) return ''
  return str.slice(0, 3) + '****' + str.slice(-4)
}
</script>

<style scoped lang="scss">

@import "@/assets/styles/minx.scss";
.radio-list{
  display: flex;
  justify-content: space-between;
  position: relative;
  align-items: center;
  height: 120rpx;
  padding: 0 40rpx;
  &::before{
    @include border(top, #E0E0E0)
  }
  .img{
    width: 40rpx;
    height: 40rpx;
    margin-right: 14rpx;
  }
}
</style>
